package org.dtrd.config.system;

import cn.hutool.core.date.DateField;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
import java.util.stream.Collectors;

/**
 * 常量定义
 *
 * @author 萧
 * @date:2021-08-19 11:22 上午
 **/
public final class Constant {

    private Constant() {
    }

    public static final String DEFAULT_PWD = "123456";
    public static final String DEFAULT_ORGCODE = "A01";

    public static final int PAGESIZE = 20;

    /**
     * 二维码默认宽度
     */
    public static final int QRCODE_DEFAULT_WIDTH = 300;

    /**
     * 二维码默认长度
     */
    public static final int QRCODE_DEFAULT_HEIGHT = 300;

    public final static String other = "其他";

    /**
     * 判断是否为固定内容的标记
     */
    public static final int FIXED = 1;

    public static final int FINISHED = 1;

    public static final int UN_FINISHED = 0;

    public static final String NO_GROUP_NAME = "未分组";

    public static final String TIME_PATTERN_SDF = "yyyy-MM-dd";

    public static final String TIME_ZONE_1 = "GMT+8";

    public static final int REMARK_LIMIT = 100;

    public static final String DEFAULT_NAME = "";

    public static final int ARCHIVE_TAG_SIGNIN = 0;

    public static final int ARCHIVE_TAG_ARCHIVING = 1;

    public static final int ASC = 1;

    public static final int DESC = 2;

    public static final int QUESTIONNAIRE_LIFEWAY_PROBLEMS = 16;

    public static final String COMPANY_NAME = "毅瑭科技";

    public static final String PLACEHOLDER = "————";

    public interface Unit {
        String MMOL_L = "mmol/L";
        String NMOL_L = "nmol/L";
        String U_L = "U/L";
        String UMOL_L = "umol/L";
        String SUGAR_VALUE_UNIT = MMOL_L;
        String AMINOTRANSFERASE_UNIT = U_L; // 转氨酶单位
        String C_PEPTIDE_UNIT = NMOL_L; // C肽单位
        String INSULIN_UNIT = "mIU/L"; // 胰岛素单位
    }


    /**
     * 打卡记录类型
     *
     * @author xiao
     * @since 2021-08-19 13:26:25
     */
    @ApiModel(value = "打卡记录类型", description = "打卡记录类型")
    public enum RecordType {
        /**
         * 血糖  icon需手动配置
         */
        SUGAR(1, "血糖", "https://imgs.dtx-tech.com/checkin/sugar"),
        /**
         * 血压
         */
        BLOOD_PRESSURE(2, "血压", "https://imgs.dtx-tech.com/checkin/blood.png"),
        /**
         * 运动
         */
        SPORT(3, "运动", "https://imgs.dtx-tech.com/checkin/sport.png"),
        /**
         * 用药
         */
        MEDICAL(4, "用药", "https://imgs.dtx-tech.com/checkin/pill.png"),
        /**
         * 饮食
         */
        DIET(5, "饮食", "https://imgs.dtx-tech.com/checkin/dinner.png"),
        /**
         * 体重
         */
        WEIGHT(6, "体重", "https://imgs.dtx-tech.com/checkin/weight.png"),
        /**
         * 腰围
         */
        WAIST(7, "腰围", "https://imgs.dtx-tech.com/checkin/waist.png"),
        /**
         * 尿酮
         */
        KETONE(8, "尿酮", "https://imgs.dtx-tech.com/checkin/test.png"),
        /**
         * 胰岛素
         */
        INSULIN(9, "胰岛素", "https://imgs.dtx-tech.com/checkin/pin.png"),
        /**
         * 睡眠
         */
        SLEEP(10, "睡眠", "https://imgs.dtx-tech.com/checkin/sleep.png"),
        /**
         * 营养素
         */
        NUTRIENT(11, "营养素", "https://imgs.dtx-tech.com/checkin/fe.png");

        private int type;
        private String name;
        private String icon;

        RecordType(int type, String name, String icon) {
            this.type = type;
            this.name = name;
            this.icon = icon;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }

        public String getIcon() {
            return icon;
        }

        public void setIcon(String icon) {
            this.icon = icon;
        }

        public static RecordType valueOf(Integer type) {
            for (RecordType value : values()) {
                if (value.type == type) {
                    return value;
                }
            }
            return null;
        }

    }

    /**
     * 打卡记录状态
     *
     * @author xiao
     * @since 2021-08-19 13:26:25
     */
    public enum RecordState {
        /**
         * 待打卡
         */
        TO_BE_RECORD(0),
        /**
         * 已打卡
         */
        RECORDED(1),
        /**
         * 漏打卡
         */
        UNRECORD(2);

        private int state;

        private RecordState(int state) {
            this.state = state;
        }

        public int getState() {
            return state;
        }

        public void setState(int state) {
            this.state = state;
        }
    }

    /**
     * 血糖记录来源
     *
     * @author xiao
     * @since 2021-08-19 13:26:25
     */
    @AllArgsConstructor
    @Getter
    public enum SugarSourceType {
        /**
         * APP
         */
        SOURCE_APP(1),
        /**
         * 微信小程序端
         */
        SOURCE_WECHAT_MINI(2),
        /**
         * 微信H5端
         */
        SOURCE_WECHAT_H5(3),
        /**
         * 卓悦/小糖医
         */
        SOURCE_XTY(4),
        /**
         * 爱奥乐
         */
        SOURCE_BIOLAND(5),
        /**
         * 微策
         */
        SOURCE_WEICE(6),
        /**
         * 瞬感伴侣 蓝牙版
         */
        SOURCE_SGBL_BLE(10);

        private int type;

        public static boolean isDeviceRecord(int type) {
            return type >= SOURCE_XTY.type && type <= SOURCE_WEICE.type;
        }

    }

    /**
     * 血糖记录类型
     *
     * @author xiao
     * @since 2021-08-19 13:26:25
     */
    @Getter
    @AllArgsConstructor
    public enum SugarRecordType {
        /**
         * 空腹
         */
        BEFOREBREAKFAST(1, "空腹"),
        /**
         * 早餐后
         */
        AFTERBREAKFAST(2, "早餐后"),
        /**
         * 午餐前
         */
        BEFORELUNCH(3, "午餐前"),
        /**
         * 午餐后
         */
        AFTERLUNCH(4, "午餐后"),
        /**
         * 晚餐前
         */
        BEFOREDINNER(5, "晚餐前"),
        /**
         * 晚餐后
         */
        AFTERDINNER(6, "晚餐后"),
        /**
         * 睡前
         */
        BEFORESLEEP(7, "睡前"),
        /**
         * 凌晨
         */
        EARLYMORNING(8, "凌晨"),

        RANDOMTIME(9, "随机");

        private int type;
        private String name;

        public static SugarRecordType valueOf(Integer type) {
            if (type != null) {
                for (SugarRecordType value : values()) {
                    if (value.type == type) {
                        return value;
                    }
                }
            }
            return null;
        }

        public static boolean isBeforeBreakfast(Integer type) {
            return type == BEFOREBREAKFAST.type;
        }

        public static boolean isBeforeMeal(Integer type) {
            return type == BEFOREBREAKFAST.type || type == BEFORELUNCH.type || type == BEFOREDINNER.type;
        }

        public static boolean isEarlyMorning(Integer type) {
            return type == EARLYMORNING.type;
        }

        public static boolean isAfterMeal(Integer type) {
            return type == AFTERBREAKFAST.type || type == AFTERLUNCH.type || type == AFTERDINNER.type;
        }

        @Override
        public String toString() {
            return "SugarRecordType{" + "type=" + type + ", name='" + name + '\'' + '}';
        }
    }

    /**
     * 饮食记录类型
     *
     * @author xiao
     * @since 2021-08-19 13:26:25
     */
    public enum FoodRecordType {
        /**
         * 空腹
         */
        BREAKFAST(1, "早餐"),
        /**
         * 午餐
         */
        LUNCH(2, "午餐"),
        /**
         * 晚餐
         */
        DINNER(3, "晚餐"),

        EXTRABREAKFAST(4, "早餐加餐"),

        EXTRALUNCH(5, "午餐加餐"),

        EXTRADINNER(6, "晚餐加餐");

        private int type;
        private String name;

        private FoodRecordType(int type, String name) {
            this.type = type;
            this.name = name;
        }

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public static FoodRecordType valueOf(Integer type) {
            for (FoodRecordType value : values()) {
                if (value.type == type) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 胰岛素记录类型
     *
     * @author xiao
     * @since 2021-08-19 13:26:25
     */
    public enum InsulinRecordType {
        /**
         * 早
         */
        MORNING(1, "早"),

        NOON(2, "午"),

        EVENING(3, "晚"),

        SLEEP(4, "睡前"),
        /**
         * 胰岛素泵
         */
        DEVICE(5, "胰岛素泵");

        private int type;
        private String name;

        private InsulinRecordType(int type, String name) {
            this.type = type;
            this.name = name;
        }

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public static InsulinRecordType valueOf(Integer type) {
            for (InsulinRecordType value : values()) {
                if (value.type == type) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 用药记录类型
     *
     * @author xiao
     * @since 2021-08-19 13:26:25
     */
    public enum MedicalRecordType {
        /**
         * 早
         */
        MORNING(1, "早"),

        NOON(2, "午"),

        EVENING(3, "晚"),

        SLEEP(4, "睡前");

        private int type;
        private String name;

        private MedicalRecordType(int type, String name) {
            this.type = type;
            this.name = name;
        }

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public static MedicalRecordType valueOf(Integer type) {
            for (MedicalRecordType value : values()) {
                if (value.type == type) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 用药情况
     */
    @AllArgsConstructor
    @Getter
    public enum MedicalSituation {
        /**
         * 遵嘱用药
         */
        MORNING(1, "遵嘱用药"),

        NOON(2, "漏用药"),

        EVENING(3, "自停药");

        private int type;
        private String name;

        public static MedicalSituation valueOf(Integer type) {
            for (MedicalSituation value : values()) {
                if (value.type == type) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 血压记录类型
     *
     * @author xiao
     * @since 2021-08-19 13:26:25
     */
    public enum BloodPressureRecordType {
        /**
         * 早
         */
        MORNING(1, "早"),

        EVENING(2, "晚"), RANDOM(3, "随机");

        private int type;
        private String name;

        private BloodPressureRecordType(int type, String name) {
            this.type = type;
            this.name = name;
        }

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public static BloodPressureRecordType valueOf(Integer type) {
            for (BloodPressureRecordType value : values()) {
                if (value.type == type) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 营养素记录类型
     */
    public enum NutrientRecordType {
        /**
         * 早
         */
        MORNING(1, "早"),

        NOON(2, "午"),

        EVENING(3, "晚"),

        SLEEP(4, "睡前");

        private int type;
        private String name;

        private NutrientRecordType(int type, String name) {
            this.type = type;
            this.name = name;
        }

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public static NutrientRecordType valueOf(Integer type) {
            for (NutrientRecordType value : values()) {
                if (value.type == type) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 运动类型
     */
    public enum SportRecordSteptype {

        WALK_FAST(1, "快走"), WALK_SLOW(2, "慢走");

        int type;

        String name;

        SportRecordSteptype(int type, String name) {
            this.type = type;
            this.name = name;
        }

        public static SportRecordSteptype valueOf(Integer type) {
            for (SportRecordSteptype value : values()) {
                if (value.type == type) {
                    return value;
                }
            }
            return null;
        }

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

    /**
     * 记录状态 记录趋势
     *
     * @author xiao
     * @since 2021-08-19 13:26:25
     */
    @Getter
    @AllArgsConstructor
    public enum RecordStatus {
        /**
         * 正常
         */
        NORMAL(2, "正常"),
        /**
         * 偏低 或者 下降
         */
        LOWER(3, "偏低"),
        /**
         * 偏高 或者 上升
         */
        HIGHER(1, "偏高");

        private int type;
        private String name;

        public static RecordStatus valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NORMAL);
        }

    }

    /**
     * 是/否
     */
    @AllArgsConstructor
    @Getter
    public enum YesOrNo {
        YES(1, "有"), NO(2, "无");

        int type;
        String name;

        public static YesOrNo valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NO);
        }
    }

    /**
     * 发送提醒状态
     *
     * @author xiao
     * @since 2021-09-27 14:27:14
     */
    public enum RemindStatus {
        /**
         * 待发送
         */
        TO_BE_REMIND(0),
        /**
         * 已发送
         */
        REMINDED(1),
        /**
         * 漏打卡已发送
         */
        MISS_RECORD_REMINDED(2);

        private int status;

        RemindStatus(int status) {
            this.status = status;
        }

        public int getStatus() {
            return status;
        }

        public void setStatus(int status) {
            this.status = status;
        }
    }

    /**
     * 发送开关状态
     *
     * @author xiao
     * @since 2021-10-16 18:26:29
     */
    public enum SendSwitch {
        /**
         * 开启发送
         */
        SEND_OPEN(0),
        /**
         * 关闭发送
         */
        SEND_OFF(1);

        private int status;

        SendSwitch(int status) {
            this.status = status;
        }

        public int getStatus() {
            return status;
        }

        public void setStatus(int status) {
            this.status = status;
        }
    }

    /**
     * 客户端类型
     */
    public enum ClientSn {
        /**
         * 小程序
         */
        CLIENTSN_XCX("xcx"),
        /**
         * 小程序-dps
         */
        CLIENTSN_XCX_DPS("xcx_dps"),
        /**
         * H5
         */
        CLIENTSN_H5("h5"),
        /**
         * 客户
         */
        CLIENTSN_CUSTOMER("customer"),
        /**
         * 员工
         */
        CLIENTSN_EMPLOYEE("employee");

        private String clientSn;

        private ClientSn(String clientSn) {
            this.clientSn = clientSn;
        }

        public String getClientSn() {
            return clientSn;
        }

        public void setClientSn(String clientSn) {
            this.clientSn = clientSn;
        }
    }

    /**
     * 用户类型
     */
    @Getter
    @AllArgsConstructor
    public enum USER_CATEGORY {
        /**
         * 医生
         */
        USER_DOCTOR("doctor"),
        /**
         * 患者
         */
        USER_PATIENT("patient");

        private String user;
    }

    /**
     * 二维码类型
     */
    @Getter
    @AllArgsConstructor
    public enum QRCODE_TYPE {
        /**
         * 1. 医生添加患者
         */
        DOCTOR_ADD_PATIENT(1),
        /**
         * 2. 医生团队二维码
         */
        DOCTOR_ADD_TEAM(2),
        /**
         * 患者个人二维码
         */
        PATIENT(3),
        /**
         * 订单二维码
         */
        ORDER(4);

        private int type;
    }

    /**
     * OSS Bucket列表
     */
    public enum OSSBUCKET {
        /**
         * 图片存储
         */
        IMAGES_GZ("images-gz");

        private String bucket;

        private OSSBUCKET(String bucket) {
            this.bucket = bucket;
        }

        public String getBucket() {
            return bucket;
        }

        public void setBucket(String bucket) {
            this.bucket = bucket;
        }
    }

    /**
     * 升糖指数
     */
    public enum FoodGlycemicIndex {
        /**
         * 低升糖
         */
        LOW(1),
        /**
         * 中升糖
         */
        MEDIUM(2),
        /**
         * 高升糖
         */
        HIGH(3);


        private int type;

        FoodGlycemicIndex(int type) {
            this.type = type;
        }

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }
    }

    /**
     * 医生类型
     */
    @AllArgsConstructor
    @Getter
    public enum DoctorType {
        // 默认0也给个医生
        NULL(0, "医生"), DEPARTMENT_DOCTOR(1, "科室医生"), DOCTOR(2, "医生"), NURSE(3, "护士/健康管理师");

        int type;

        String name;

        public static DoctorType valueOf(int type) {
            for (DoctorType value : values()) {
                if (value.type == type) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 职称与字典数据表对应一致 需同步关联修改  肖 2022-06-21 15:38:01
     */
    @AllArgsConstructor
    @Getter
    public enum JobTitle {
        // 默认0也给个医生
        DEPARTMENT_DOCTOR(1, "科室医生"), DOCTOR(2, "医生"), NURSE(3, "护士/健康管理师");

        int type;

        String name;

    }

    @Getter
    @AllArgsConstructor
    public enum DoctorTags {

        INCRETION("内分泌", 1), METABOLISM("代谢", 2), COMPLICATIONSOFDIABETES("糖尿病并发症", 3), PREVENTIONANDSCREENING("预防与筛查", 4), OBESITY("肥胖症", 5), FATLOSS("减脂", 6), LIFESTYLEINTERVENTIONS("生活方式干预", 7), NUTRITION("营养", 8), HYPERTENSION("高血压", 9), DIABETESEDUCATION("糖尿病教育", 10);

        private String name;
        private int value;

        public static DoctorTags valueOf(Integer value) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getValue(), value)).findAny().orElse(INCRETION);
        }
    }

    /**
     * 复诊状态
     */
    public enum OutpatientStatus {

        /**
         * 不可预约
         */
        UNABLE(0),
        /**
         * 可预约
         */
        ABLE(1);

        public static OutpatientStatus valueOf(int status) {
            for (OutpatientStatus value : values()) {
                if (value.status == status) {
                    return value;
                }
            }
            return null;
        }


        OutpatientStatus(int status) {
            this.status = status;
        }

        int status;

        public int getStatus() {
            return status;
        }

        public void setStatus(int status) {
            this.status = status;
        }
    }

    /**
     * 睡眠状况类型
     */
    @Getter
    @AllArgsConstructor
    public enum SleepStatus {
        NORMAL(1, "正常"), EARLY(2, "早睡"), LATE(3, "晚睡"), INSOMNIA(4, "失眠");

        int type;

        String SleepStatusDesc;

        public static SleepStatus valueOf(int type) {
            for (SleepStatus value : values()) {
                if (value.type == type) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 状态类型
     */
    @AllArgsConstructor
    @Getter
    public enum NormalStatus {

        NORMAL(1, "正常"), UN_NORMAL(2, "异常");

        int type;
        String name;

        public static NormalStatus valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NORMAL);
        }
    }

    /**
     * 眼底检查状况
     */
    @AllArgsConstructor
    @Getter
    public enum EyeCheck {
        ITEM_1(1, "有(<=一个象限)"), ITEM_2(2, "有(>一个象限)"), NO(3, "无");

        int type;
        String name;

        public static EyeCheck valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NO);
        }
    }

    /**
     * 检测状况类型
     */
    @AllArgsConstructor
    @Getter
    public enum Exam {
        ABNORMAL(1, "异常"), NORMAL(2, "无异常");

        int type;
        String name;

        public static Exam valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NORMAL);
        }
    }

    /**
     * ABI 检查选项
     */
    @AllArgsConstructor
    @Getter
    public enum ABI {
        ABI_1(1, "<=0.9"), ABI_2(2, "0.9 ~ 1.3"), ABI_3(3, ">1.3");

        int type;
        String name;

        public static ABI valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(ABI_1);
        }
    }

    /**
     * TBI 检查选项
     */
    @AllArgsConstructor
    @Getter
    public enum TBI {
        TBI_1(1, "<0.6"), TBI_2(2, ">=0.6");

        int type;
        String name;

        public static TBI valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    /**
     * TcPo2 检查选项
     */
    @AllArgsConstructor
    @Getter
    public enum TcPO2 {
        TCPO2_1(1, "<30mmHg"), TCPO2_2(2, ">=30mmHg");

        int type;
        String name;

        public static TcPO2 valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(TCPO2_1);
        }
    }

    /**
     * 溃疡检查选项
     */
    @AllArgsConstructor
    @Getter
    public enum Ulceration {

        ULCERATION_1(1, "浅表溃疡"), ULCERATION_2(2, "较深溃疡"), ULCERATION_3(3, "深度溃疡");

        int type;
        String name;

        public static Ulceration valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(ULCERATION_1);
        }
    }

    /**
     * 坏疽检查选项
     */
    @AllArgsConstructor
    @Getter
    public enum Gangrene {

        NULL(0, "无"), Gangrene_1(1, "局部性坏疽"), Gangrene_2(2, "全足坏疽");

        int type;
        String name;

        public static Gangrene valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NULL);
        }
    }

    /**
     * 阴性/阳性
     */
    @AllArgsConstructor
    @Getter
    public enum YinYang {
        YIN(1, "阴性"), YANG(2, "阳性");

        int type;
        String name;

        public static YinYang valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(YIN);
        }
    }

    /**
     * 动脉听诊检查选项
     */
    @AllArgsConstructor
    @Getter
    public enum AuscultationStatus {
        HAS_NOISE(1, "有杂音"), NO_NOISE(2, "无杂音");

        int type;
        String name;

        public static AuscultationStatus valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NO_NOISE);
        }
    }

    /**
     * 感觉类检查选项
     */
    @AllArgsConstructor
    @Getter
    public enum PeripheralItem {
        NORMAL(1, "正常"), MISSING(2, "缺失"), LESS(3, "减弱"), MORE(4, "亢进");

        int type;
        String name;

        public static PeripheralItem valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NORMAL);
        }
    }

    /**
     * 患病状况
     */
    @AllArgsConstructor
    @Getter
    public enum DiabetesDiagnose {

        DIAGNOSE(1, "确诊有"), DIAGNOSE_NO(2, "确诊无"), HAS_NOT_DIAGNOSE(3, "未确诊");

        int type;
        String name;

        public static DiabetesDiagnose valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(HAS_NOT_DIAGNOSE);
        }
    }

    /**
     * 确诊状况
     */
    @AllArgsConstructor
    @Getter
    public enum DiagnoseStatus {

        UNDIAGNOSED(1, "未确诊"), HAD_DIAGNOSED(2, "已确诊");

        int type;
        String name;

        public static DiagnoseStatus valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(UNDIAGNOSED);
        }
    }

    /**
     * 脑卒类型
     */
    @AllArgsConstructor
    @Getter
    public enum CerebrovascularType {

        CEREBROVASCULAR_TYPE_1(1, "缺血性脑卒中"), CEREBROVASCULAR_TYPE_2(2, "出血性脑卒中"), CEREBROVASCULAR_TYPE_3(3, "其他");

        int type;
        String name;

        public static CerebrovascularType valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    /**
     * 周围血管疾病类型
     */
    @AllArgsConstructor
    @Getter
    public enum PeripheralType {
        PERIPHERAL_TYPE_1(1, "外周动脉疾病"), PERIPHERAL_TYPE_2(2, "动脉瘤"), PERIPHERAL_TYPE_3(3, "动静脉瘘"), PERIPHERAL_TYPE_4(4, "外周静脉疾病"), PERIPHERAL_TYPE_5(5, "周围血管损伤");

        int type;
        String name;

        public static PeripheralType valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(PERIPHERAL_TYPE_1);
        }
    }

    /**
     * 控制目标状态
     */
    public enum TargetStatus {

        USING(1), UNUSED(0);

        int type;

        TargetStatus(int type) {
            this.type = type;
        }

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }
    }

    /**
     * 控制目标类型
     */
    @AllArgsConstructor
    @Getter
    public enum TargetProject {
        /**
         *
         */
        BMI(1, "BMI", "18.5~23.9"),
        WEIGHT(2, "体重(kg)", "65.0"),
        WAIST(3, "腰围(cm)", "<90.0"),
        HBA1C(4, "糖化血红蛋白(%)", "<7.0"),
        FBG(5, "空腹血糖(mmol/L)", "6.0~8.0"),
        PBG(6, "餐后血糖(mmol/L)", "6.0~8.0"),
        PRESSURE_LOW(7, "舒张压/低压 mmHg", "<80.0"),
        PRESSURE_HIGH(8, "收缩压/高压 mmHg", "<140.0"),
        HEART_RATE(9, "心率/脉搏(次/分钟)", "60~100"),
        TC(10, "总胆固醇(mmol/L)", "<4.5"),
        TG(11, "甘油三酯(mmol/L)", "<1.7"),
        LDL(12, "低密度脂蛋白(mmol/L)", "<2.6"),
        HDL(13, "高密度脂蛋白(mmol/L)", ">1.0"),
        DRUG(14, "用药情况", ""),
        BIL(15, "总胆红素(umol/L)", "0~23"),
        AST(16, "谷草转氨酶(U/L)", "13~35"),
        ALP(17, "碱性磷酸酶(U/L)", "40~110"),
        UAE(18, "尿微量白蛋白(ug/min)", "23~62"),
        UAE_24H(19, "24h尿白蛋白(mg/24h)", "40~80"),
        ACR(20, "尿白蛋白/尿肌酐(mg/g)", "40~80"),
        Cr(21, "血清肌酐(ummol/L)", "44~133"),
        UREANITROGEN(22, "尿素氮(mmol/L)", "3.2~7.1"),
        GFR(23, "肾小球滤过率", "600~1000"),
        CrCl(24, "内生肌酐清除率", "0.45~1.32"),
        ALT(25, "谷丙转氨酶(U/L)", "7~40"),
        BUA(26, "血尿酸(mmol/L)", "180~420");
        // 13-2 11-3 2-4 3-5 5-6 5-7 6-8 12-9 7-10 8-11 9-13 10-12

        int type;
        String name;
        String referenceValue;

        public static TargetProject valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(BMI);
        }

        public static TargetProject valueOfName(String type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getName(), type)).findAny().orElse(null);
        }
    }

    /**
     * 银行卡用户类型
     */
    public enum BankUserType {

        DOCTOR(2);

        int type;

        BankUserType(int type) {
            this.type = type;
        }

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }
    }

    /**
     * 医生部门
     */
    @AllArgsConstructor
    @Getter
    public enum Departments {

        NULL(0, "暂无"), PATHOLOGY_DEPARTMENT(1, "病理科");

        int type;
        String name;


        public static Departments valueOf(int type) {
            return Arrays.stream(values()).filter(c -> c.getType() == type).findAny().orElse(NULL);
        }
    }

    /**
     * 医院
     */
    @AllArgsConstructor
    @Getter
    public enum Hospital {

        NO(0, "暂无"), PEOPLE_HOSPITAL(1, "广东省人民医院");

        int type;
        String name;

        public static Hospital valueOf(int type) {
            return Arrays.stream(values()).filter(c -> c.getType() == type).findAny().orElse(NO);
        }
    }

    /**
     * 职称
     */
    @AllArgsConstructor
    @Getter
    public enum Level {

        NULL(0, "暂无"), ATTENDING_DOCTOR(1, "主治医生");

        int type;
        String name;

        public static Level valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(type, c.getType())).findAny().orElse(ATTENDING_DOCTOR);
        }
    }

    /**
     * 家属关系
     */
    @AllArgsConstructor
    @Getter
    public enum FamilyRelation {
        Father(1, "父亲"), Mother(2, "母亲"), HusBand(3, "丈夫"), Wife(4, "妻子"), Grandpa(5, "爷爷"), Grandma(6, "奶奶"), GrandpaInLaw(7, "外公"), GrandmaInLaw(8, "外婆"), Son(9, "儿子"), Daughter(10, "女儿"), Relative(11, "亲戚"), Other(12, "其他");
        int type;
        String name;

        public static FamilyRelation valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(Other);
        }
    }

    /**
     * 劳动类型
     */
    @AllArgsConstructor
    @Getter
    public enum Occupation {
        LightPhysicalLabor(1, "轻体力劳动"), NormalPhysicalLabor(2, "中体力劳动"), HeavyPhysicalLabor(3, "重体力劳动");

        int type;
        String name;

        public static Occupation valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NormalPhysicalLabor);
        }
    }

    /**
     * 教育状况
     */
    @AllArgsConstructor
    @Getter
    public enum Education {

        Null(1, "未读"), PrimarySchool(2, "小学"), JuniorHighSchool(3, "初中"), SeniorHighSchool(4, "高中"), TechnicalSecondarySchool(5, "中专"), JuniorCollege(6, "大专"), Undergraduate(7, "本科"), Master(8, "硕士");

        int type;
        String name;

        public static Education valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(Undergraduate);
        }
    }

    /**
     * 生病类型
     */
    @AllArgsConstructor
    @Getter
    public enum IsSicked {
        IS_SICKED(1, "是"), IS_NOT_SICKED(2, "否");

        int type;
        String name;

        public static IsSicked valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(IS_NOT_SICKED);
        }
    }

    @AllArgsConstructor
    @Getter
    public enum DrugType {
        NO(0, "未用药"), ORAL_DRUG(1, "口服药"), INSULIN(2, "胰岛素");

        int type;
        String name;

        public static DrugType valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NO);
        }
    }

    /**
     * 怀孕类型
     */
    @AllArgsConstructor
    @Getter
    public enum Gestation {

        Null(0, "无"), PreparingForPregnancy(1, "备孕中"), DuringPregnancy(2, "妊娠中"), LactationPeriod(3, "哺乳期");

        int type;
        String name;

        public static Gestation valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(Null);
        }
    }

    /**
     * 患者属性
     */
    @AllArgsConstructor
    @Getter
    public enum PatientProperty {

        Outpatient(1, "门诊"), BeHospitalized(2, "住院");

        int type;
        String name;

        public static PatientProperty valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(Outpatient);
        }
    }

    /**
     * 医疗支付方式
     */
    @AllArgsConstructor
    @Getter
    public enum PayMode {
        BasicSocialMedicalInsurance(1, "社会医疗基本保险"), NewRuralCooperativeMedicalInsurance(2, "新型农村合作医疗保险"), UrbanResidentsMedicalInsurance(3, "城镇居民医疗保险"), BusinessInsurance(4, "商业保险"), PublicMedical(5, "公费医疗"), SelfFinanced(6, "自费医疗"), Other(7, "其它");

        int type;
        String name;

        public static PayMode valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(BasicSocialMedicalInsurance);
        }
    }

    /**
     * 婚姻状态
     */
    @AllArgsConstructor
    @Getter
    public enum MaritalStatus {
        Married(1, "已婚"), Unmarried(2, "未婚"), Single(3, "单身"), Widowed(4, "丧偶");

        int type;
        String name;

        public static MaritalStatus valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(Single);
        }
    }

    /**
     * 周期单位
     */
    @Getter
    @AllArgsConstructor
    public enum PeriodUnit {
        /**
         *
         */
        DAY(1, "天", DateField.DAY_OF_MONTH), MONTH(2, "月", DateField.MONTH), YEAR(3, "年", DateField.YEAR), WEEK(4, "周", DateField.WEEK_OF_YEAR);

        int type;
        String name;
        DateField field;

        public static PeriodUnit valueOf(int type) {
            for (PeriodUnit periodUnit : values()) {
                if (periodUnit.type == type) {
                    return periodUnit;
                }
            }
            return null;
        }

    }

    /**
     * 逆转结果
     */
    @AllArgsConstructor
    @Getter
    public enum ReversionResult {
        NOT_SATISFY(0, "无"), SATISFY_1(1, ""), SATISFY_2(2, "根据您的糖尿病并发症情况，需要进行心肺功能评估；为避免发生意外，逆转过程及生活中需避免高强度运动。"), SATISFY_3(3, "根据您的糖尿病并发症情况，需要进行心肺功能评估；为避免发生意外，逆转过程及生活中需避免高强度运动；不宜使用生酮饮食和高蛋白饮食逆转方案。"), SATISFY_4(4, "根据您的糖尿病并发症情况，不宜使用生酮饮食和高蛋白饮食逆转方案。");

        int type;
        String name;

        public static ReversionResult valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NOT_SATISFY);
        }
    }

    /**
     * 性别
     */
    @AllArgsConstructor
    @Getter
    public enum Sex {
        NO(0, "暂无"), MAN(1, "男"), WOMAN(2, "女");

        int type;

        String name;

        public static Sex valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NO);
        }
    }

    /**
     * 糖尿病类型
     */
    @AllArgsConstructor
    @Getter
    public enum DiabetesType {
        NO(0, "未确诊"), DIABETES_TYPE_1(1, "1型糖尿病"), DIABETES_TYPE_2(2, "2型糖尿病"), DIABETES_TYPE_PREGNANCY(3, "妊娠型糖尿病"), DIABETES_TYPE_OTHER(4, "其他类型糖尿病");

        int type;

        String name;

        public static DiabetesType valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NO);
        }
    }

    /**
     * 分组
     */
    @AllArgsConstructor
    @Getter
    public enum Group {
        NO_GROUP(0, "未分组"), IN_MANAGE(1, "在管"), CONTINUE_MANAGE(2, "续管"), FINISHED(3, "已完成");

        int type;
        String name;

        public static Group valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> c.getType() == type).findAny().orElse(NO_GROUP);
        }
    }

    /**
     * 银行卡状态
     */
    @AllArgsConstructor
    @Getter
    public enum BankCardStatus {

        DEFAULT(1, "默认");

        int type;
        String name;
    }

    /**
     * 银行信息
     */
    @AllArgsConstructor
    @Getter
    public enum BankInfo {

        BOC(1, "中国银行"), CCB(2, "建设银行"), ICBC(3, "招商银行"), AGRICULTURAL_BANk(4, "农业银行"), COMMUNICATIONS_BANK(5, "交通银行");

        int type;
        String name;

        public static BankInfo valueOf(int type) {
            for (BankInfo bank : values()) {
                if (bank.getType() == type) {
                    return bank;
                }
            }
            return null;
        }
    }

    /**
     * 星期
     */
    @AllArgsConstructor
    @Getter
    public enum WeekDay {
        Sunday(0, "星期日"), Monday(1, "星期一"), Tuesday(2, "星期二"), Wednesday(3, "星期三"), Thursday(4, "星期四"), Friday(5, "星期五"), Saturday(6, "星期六");

        int type;
        String name;

        public static WeekDay valueOf(int type) {
            return Arrays.stream(values()).filter(c -> c.getType() == type).findAny().orElse(Monday);
        }
    }

    /**
     * 患者复诊状态
     */
    @AllArgsConstructor
    @Getter
    public enum FlupStatus {

        NoAppointment(0, "未预约"), WaitToVisit(1, "待复诊"), HadVisited(2, "已复诊"), NotVisited(3, "未复诊"), Visiting(4, "复诊中"), HasAppointment(5, "已预约");

        int status;
        String name;

        public static FlupStatus valueOf(int status) {
            return Arrays.stream(values()).filter(c -> c.getStatus() == status).findAny().orElse(NoAppointment);
        }
    }

    /**
     * 量表信息
     */
    @AllArgsConstructor
    @Getter
    public enum Evaluation {
        NULL(0, "无"), SDSCA(1, "自我管理行为（SDSCA）"), CDMSES(2, "自我管理效能（C-DMSES）"), DCP(3, "密西根糖尿病管理评定表（DCP）"), ADKnowl(4, "患者知识量表（ADKnowl）"), MMAS8(5, "Morisky用药依从性问卷（MMAS-8）"), BMQ(6, "服药信念量表（BMQ）"), DIABETES(11, "糖尿病风险评估"), CVD(12, "心血管10年风险评估"), SAS(13, "焦虑自评（SAS）"), SDS(14, "抑郁自评（SDS）"), PF(15, "卡特尔十六种人格因素测验（16PF）"), JOB(16, "马氏工作倦怠通用量表"), MMPI(17, "明尼苏达多相个性测查表"), PSQI(18, "匹兹堡睡眠质量指数（PSQI）"), SCL(19, "心理健康临床症状自评测验（SCL-90）"), HAPPY(20, "总体幸福感测试"), PARQ(21, "体能活动就绪问卷"), NRS(22, "营养风险筛查评估表");

        int id;
        String name;

        public static Evaluation valueOf(int id) {
            return Arrays.stream(values()).filter(evaluation -> evaluation.id == id).findAny().orElse(NULL);
        }
    }

    /**
     * 复诊时间段
     */
    @AllArgsConstructor
    @Getter
    public enum FlupTime {
        DEFAULT(0, "00:00", "23:59"), FlupTime1(1, "08:50", "09:10"), FlupTime2(2, "09:10", "09:30"), FlupTime3(3, "09:30", "09:50"), FlupTime4(4, "09:50", "10:10"), FlupTime5(5, "10:10", "10:30"), FlupTime6(6, "10:30", "10:50"), FlupTime7(7, "10:50", "11:10"), FlupTime8(8, "11:10", "11:30"), FlupTime9(9, "11:30", "11:50"), FlupTime10(10, "14:00", "14:20"), FlupTime11(11, "14:20", "14:40"), FlupTime12(12, "14:40", "15:00"), FlupTime13(13, "15:00", "15:20"), FlupTime14(14, "15:20", "15:40"), FlupTime15(15, "15:40", "16:00"), FlupTime16(16, "16:00", "16:20"), FlupTime17(17, "16:20", "16:40"), FlupTime18(18, "16:40", "17:00"), FlupTime19(19, "17:00", "17:20"), FlupTime20(20, "18:30", "18:50"), FlupTime21(21, "18:50", "19:20"), FlupTime22(22, "19:20", "19:50");

        int type;
        String startTime;
        String endTime;

        public static FlupTime valueOf(int type) {
            return Arrays.stream(values()).filter(time -> time.getType() == type).findAny().orElse(FlupTime13);
        }
    }

    /**
     * 打卡结果状态
     */
    @AllArgsConstructor
    @Getter
    public enum SigninRecordStat {
        /**
         * 天汇总
         */
        DateStat(1),
        /**
         * 周平均
         */
        WeekStat(2),
        /**
         * 月平均
         */
        MonthStat(3);

        int type;

        public static SigninRecordStat valueOf(int type) {
            return Arrays.stream(values()).filter(record -> record.type == type).findFirst().orElse(DateStat);
        }
    }

    /**
     * 二维码类型
     */
    @AllArgsConstructor
    @Getter
    public enum QrCodeType {

        NULL(0), // 复诊接待码
        FlupReception(1), // 复诊完成码
        FlupFinished(2);

        int type;

        public static QrCodeType valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NULL);
        }
    }

    /**
     * 影像学检查选项
     */
    @AllArgsConstructor
    @Getter
    public enum IconographyItem {
        NORMAL(1, "正常"), ABNORMAL(2, "提示下肢血管病变"), OTHER(3, "其他");

        int type;
        String name;

        public static IconographyItem valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NORMAL);
        }
    }

    /**
     * 服务包的服务状态
     */
    @AllArgsConstructor
    @Getter
    public enum PackageServiceStatus {

        /**
         *
         */
        NO_SERVICE(0, "没有服务"), SERVICING(1, "服务中"), WAIT_TO_SERVICE(2, "待服务"), FINISHED(3, "已结束"), QUIT(4, "已退出"), EXPIRE(5, "已到期");

        int type;
        String name;

        public static PackageServiceStatus valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(WAIT_TO_SERVICE);
        }

        /**
         * 限进行中和已到期可以退出
         *
         * @param type
         * @return
         */
        public static boolean isQuitAble(Integer type) {
            if (type == null) {
                return false;
            }
            return type == SERVICING.type || type == EXPIRE.type;
        }

        /**
         * 服务包是否已结束
         * 已退出和已结束
         *
         * @param type
         * @return
         */
        public static boolean isServiceEnd(Integer type) {
            if (type == null) {
                return false;
            }
            return type == FINISHED.type || type == QUIT.type;
        }

    }

    /**
     * 服务包类型
     */
    @AllArgsConstructor
    @Getter
    public enum ServicePackageType {
        /**
         * 体验式服务包
         */
        EXPERIENCE(2),
        /**
         * 普通
         */
        NORMAL(1), VIP(3);

        int type;

        public static ServicePackageType valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NORMAL);
        }
    }

    /**
     * 打卡计划使用状态
     */
    @AllArgsConstructor
    @Getter
    public enum SignInPlanUsageStatus {

        NotStart(0, "未开始"), Using(1, "使用中"), Finished(2, "已结束"), Pause(3, "暂停中");

        int type;
        String name;

        public static SignInPlanUsageStatus valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NotStart);
        }
    }

    /**
     * 打卡单项状态
     */
    @AllArgsConstructor
    @Getter
    public enum SigninItemPlanStatus {

        /**
         * 已打卡
         */
        NORMAL(1, "正常", null),
        UN_RECORD(2, "漏打", null),
        FUTURE(3, "没到时间", "未打卡"),
        NOPLAN(4, "未配置计划", "-");

        int type;
        String name;
        String status;

        public static SigninItemPlanStatus valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(UN_RECORD);
        }

        /**
         * 根据打卡项状态转换为记录
         *
         * @param recordState
         * @return
         */
        public static Integer valueOfRecordState(Integer recordState) {
            if (recordState == 0) {
                return FUTURE.type;
            }
            return recordState;
        }


    }

    /**
     * 日血糖波动幅度
     */
    @AllArgsConstructor
    @Getter
    public enum SugarWave {
        STATUS_1(1, "<3.9mmol/L"), STATUS_2(2, ">=3.9mmol/L");

        int type;
        String name;

        public static SugarWave valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    /**
     * 执行者类型
     */
    @AllArgsConstructor
    @Getter
    public enum Executor {
        /**
         * 团队成员角色
         */
        NULL(0, "", "暂无"),
        NURSE(1, "nurse", "医助"),
        NUTRITION_MANAGER(2, "yingyangshi", "营养师"),
        HEALTH_MANAGER(3, "jianguanshi", "健康管理师"),
        PSYCHOLOGICAL_COUNSELOR(4, "zixunshi", "心理咨询师"),
        SPORT_THERAPIST(5, "kangfushi", "运动康复师"),
        DOCTOR(6, "zhuren", "责任医生"),
        MANAGE_DOCTOR(7, "manage", "主任医生");

        int type;
        String code;
        String name;

        public static Executor valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    @AllArgsConstructor
    @Getter
    public enum LoginIdentity {
        DEFAULT(0, "无"), PATIENT(1, "患者"), DOCTOR(2, "医生");

        int type;
        String name;

        public static LoginIdentity valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(DEFAULT);
        }
    }

    /**
     * 打卡项目:1 血糖；2血压；3运动；4用药；5 饮食；6 体重；7腰围；8尿酮；9 胰岛素；10睡眠
     */
    @AllArgsConstructor
    @Getter
    public enum SuggestType {
        /**
         *
         */
        NULL(0, "无"), BLOOD_SUGAR(1, "血糖"), BLOOD_PRESSURE(2, "血压"), SPORT(3, "运动"), MEDICAL(4, "用药"), DIET(5, "饮食"), WEIGHT(6, "体重"), WAIST(7, "腰围"), KETONE(8, "尿酮"), INSULIN(9, "胰岛素"), SLEEP(10, "睡眠"),
        SUMMARY(11, "总结"), LIFESTYLE(12, "生活方式"), NUTRIENT(13, "营养素"), MANAGEMENT(14, "日常管理");

        int type;
        String name;

        public static SuggestType valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NULL);
        }

        public static List<SuggestType> effectiveValues() {
            return Arrays.stream(values()).filter(suggestType -> suggestType.type > 0).collect(Collectors.toList());
        }

    }

    /**
     * 打卡完成状态
     */
    @AllArgsConstructor
    @Getter
    public enum SigninDoneStatus {
        WAIT_TO_SIGNIN(0, "待打卡"), HAD_SIGNIN(1, "已打卡"), NO_SIGNIN(2, "漏打卡");

        int type;
        String name;

        public static SigninDoneStatus valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(WAIT_TO_SIGNIN);
        }
    }

    /**
     * 服务项状态
     */
    @AllArgsConstructor
    @Getter
    public enum ServiceItemStatus {
        NOT_DONE(0, "未完成"), HAS_DONE(1, "已完成");

        int type;
        String name;

        public static ServiceItemStatus valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NOT_DONE);
        }
    }

    /**
     * 报告类型
     */
    @AllArgsConstructor
    @Getter
    public enum ReportType {
        REPORT_FIRST(1, "首诊报告"), REPORT_WEEK(2, "第n周报告"), REPORT_MONTH(3, "第n月报告"), REPORT_SUMMARY(4, "总结报告");

        int type;
        String name;

        public static ReportType valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    /**
     * 微信公众号事件
     */
    @AllArgsConstructor
    @Getter
    public enum WxEvent {
        /**
         * 关注
         */
        SUBSCRIBE("subscribe"),
        /**
         * 取消关注
         */
        UNSUBSCRIBE("unsubscribe"),
        /**
         * 扫码回调
         */
        SCAN("SCAN");
        private String event;

        public static WxEvent typeOf(String event) {
            if (event == null) {
                return null;
            }
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getEvent(), event)).findAny().orElse(null);
        }

    }

    /**
     * 逆转问卷结果
     */
    @AllArgsConstructor
    @Getter
    public enum QuestionnaireResult {
        RESULT_0(0, "很抱歉，您暂不符合逆转条件，请与您的医助联系。", ""), RESULT_1(1, "您符合逆转条件，请与您的医助联系或到店咨询逆转服务。", ""), RESULT_2(1, "您符合逆转条件，请与您的医助联系或到店咨询逆转服务。", "根据您的糖尿病并发症情况，需要进行心肺功能评估；为避免发生意外，逆转过程及生活中需避免高强度运动。"), RESULT_3(1, "您符合逆转条件，请与您的医助联系或到店咨询逆转服务。", "根据您的糖尿病并发症情况，需要进行心肺功能评估；为避免发生意外，逆转过程及生活中需避免高强度运动；不宜使用生酮饮食和高蛋白饮食逆转方案。"), RESULT_4(1, "您符合逆转条件，请与您的医助联系或到店咨询逆转服务。", "根据您的糖尿病并发症情况，不宜使用生酮饮食和高蛋白饮食逆转方案。");

        int type;
        String desc;
        String remark;

        public static QuestionnaireResult valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    /**
     * 企微机器人消息类型
     */
    @AllArgsConstructor
    @Getter
    public enum RobotMsgType {
        /**
         * 文本
         */
        TEXT(1, "text"),
        /**
         * markdown 格式
         */
        MARKDOWN(2, "markdown"),
        /**
         * 图片
         */
        IMAGE(3, "image"),
        /**
         * 图文
         */
        NEWS(4, "news"),
        /**
         * 文件
         */
        FILE(5, "file"),
        /**
         * 文本通知文本
         */
        TEXT_NOTICE(6, "text_notice"),
        /**
         * 图片通知类型
         */
        NEWS_NOTICE(7, "news_notice");


        int type;
        String name;

        public static RobotMsgType valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    /**
     * 微信菜单事件类型
     */
    @AllArgsConstructor
    @Getter
    public enum WechatMenuType {
        /**
         * 网页类型
         */
        view,
        /**
         * 点击类型
         */
        click,
        /**
         * 小程序类型
         */
        miniprogram;
    }

    /**
     * 血糖限制类型
     */
    @AllArgsConstructor
    @Getter
    public enum SugarValueUplowType {
        EARLY_MORNING(1, "凌晨"), LIMOSIS(2, "空腹"), AFTER_MEAL(3, "餐后"), BEFORE_SLEEP(4, "睡前"), BEFORE_MEAL(5, "餐前");

        int type;
        String name;

        public static SugarValueUplowType valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    /**
     * 小程序事件
     */
    @AllArgsConstructor
    @Getter
    public enum MiniProgramEventType {
        jump_webpage, jump_mini, jump_localpage, page;
    }

    /**
     * 患者的打卡状态
     */
    @AllArgsConstructor
    @Getter
    public enum PatientSigninStatus {
        /**
         * 未配置计划
         */
        NO_PLAN(5),
        /**
         * 未开始
         */
        NO_START(1),
        /**
         * 使用中
         */
        USING(2),
        /**
         * 已结束
         */
        HAD_FINISHED(3),
        /**
         * 暂定中
         */
        PAUSE(4),
        /**
         * 未购买
         */
        NO_SERVICE(0);

        int type;

        public static PatientSigninStatus valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    /**
     * 数据达标状况
     */
    @AllArgsConstructor
    @Getter
    public enum ReachStandardStatus {
        REACH(1, "达标"), NO_REACH(0, "未达标");

        int type;
        String name;

        public static ReachStandardStatus valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    /**
     * 医生二维码类型
     */
    @AllArgsConstructor
    @Getter
    public enum DoctorQrCodeType {
        /**
         * 1. 添加患者
         */
        ADD_PATIENT(1),
        /**
         * 2. 加入团队
         */
        ADD_TEAM(2);

        int type;

        public static DoctorQrCodeType valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    /**
     * 报告的发布状态
     */
    @AllArgsConstructor
    @Getter
    public enum ReportPublishType {
        NO_PUBLISH(0, "待发布"), HAD_PUBLISHED(1, "已发布");

        int type;
        String name;

        public static ReportPublishType valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NO_PUBLISH);
        }
    }

    @AllArgsConstructor
    @Getter
    public enum TargetUsageStatus {

        NO_USE(0, "未使用"), USING(1, "使用中");

        int type;
        String name;

        public static TargetUsageStatus valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NO_USE);
        }
    }

    /**
     * 患者数据的对比结果
     */
    @AllArgsConstructor
    @Getter
    public enum PatientDataCompare {
        EQUAL(0, "相等"), RISE(1, "上升"), DECLINE(2, "下降");

        int type;
        String name;

        public static PatientDataCompare valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    @AllArgsConstructor
    @Getter
    public enum FlupItemStatus {

        NOT_FINISHED(0, "未完成"), HAD_FINISHED(1, "已完成");

        int type;
        String name;

        public static FlupItemStatus valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(NOT_FINISHED);
        }
    }

    @AllArgsConstructor
    @Getter
    public enum Avatar {
        AVATAR_1(1, 2, 3, "https://images-gz.oss-cn-guangzhou.aliyuncs.com/upload/健管师女-圆_1649755792248.png"), AVATAR_2(2, 2, 3, "https://images-gz.oss-cn-guangzhou.aliyuncs.com/upload/健管师女-方_1649755855716.png"), AVATAR_3(1, 1, 3, "https://images-gz.oss-cn-guangzhou.aliyuncs.com/upload/健管师男-圆_1649755889874.png"), AVATAR_4(2, 1, 3, "https://images-gz.oss-cn-guangzhou.aliyuncs.com/upload/健管师男-方_1649755920724.png"), AVATAR_5(1, 2, 6, "https://images-gz.oss-cn-guangzhou.aliyuncs.com/upload/医生女-圆_1649755970857.png"), AVATAR_6(2, 2, 6, "https://images-gz.oss-cn-guangzhou.aliyuncs.com/upload/医生女-方_1649756000880.png"), AVATAR_7(1, 1, 6, "https://images-gz.oss-cn-guangzhou.aliyuncs.com/upload/医生男-圆_1649756035918.png"), AVATAR_8(2, 1, 6, "https://images-gz.oss-cn-guangzhou.aliyuncs.com/upload/医生男-方_1649756065698.png"), AVATAR_9(1, 2, 2, "https://images-gz.oss-cn-guangzhou.aliyuncs.com/upload/营养师女-圆_1649756114458.png"), AVATAR_10(2, 2, 2, "https://images-gz.oss-cn-guangzhou.aliyuncs.com/upload/营养师女-方_1649756144599.png"), AVATAR_11(1, 1, 2, "https://images-gz.oss-cn-guangzhou.aliyuncs.com/upload/营养师男-圆_1649756178451.png"), AVATAR_12(2, 1, 2, "https://images-gz.oss-cn-guangzhou.aliyuncs.com/upload/营养师男-方_1649756218755.png"),
        ;

        /**
         * 头像类型，1-圆，2-方
         */
        int imageType;
        int sex;
        /**
         * @see Constant.Executor
         */
        int doctorType;
        String url;

        public static String valueOf(Integer sex, Integer doctorType, Integer imageType) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getSex(), sex) && Objects.equals(c.getDoctorType(), doctorType) && Objects.equals(c.getImageType(), imageType)).findAny().map(Avatar::getUrl).orElse(null);
        }
    }

    /**
     * 打卡率百分比常量
     */
    @AllArgsConstructor
    @Getter
    public enum SigninPlanPercentage {
        PERCENTAGE_1(1, "0~10%"), PERCENTAGE_2(2, "10~20%"), PERCENTAGE_3(3, "20~30%"), PERCENTAGE_4(4, "30~40%"), PERCENTAGE_5(5, "40~50%"), PERCENTAGE_6(6, "50~60%"), PERCENTAGE_7(7, "60~70%"), PERCENTAGE_8(8, "70~80%"), PERCENTAGE_9(9, "80~90%"), PERCENTAGE_10(10, "90~100%");

        int type;
        String name;

        public static SigninPlanPercentage valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    /**
     * 机构等级
     */
    @AllArgsConstructor
    @Getter
    public enum OrganizationLevelStatus {
        LEVEL_1(1, "未指定"), LEVEL_2(2, "三级甲等"), LEVEL_3(3, "二级甲等"), LEVEL_4(4, "一级甲等");

        int type;
        String name;

        public static OrganizationLevelStatus valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    @AllArgsConstructor
    @Getter
    public enum UpdateSummaryReportType {

        PHYSICAL(1), LAB(2), ICONOGRAPHY(3);

        int type;

        public static UpdateSummaryReportType valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(null);
        }
    }

    /**
     * 医患关系类型
     */
    @AllArgsConstructor
    @Getter
    public enum DoctorPatientRelationType {

        /**
         * 后台添加
         */
        ADD_BY_OMS(1),
        /**
         * 医生微信扫码患者添加
         */
        ADD_BY_SCAN_PATIENT(2),
        /**
         * 患者微信扫码医生添加
         */
        ADD_BY_PATIENT_SCAN(3),
        /**
         * 小程序端患者扫码医生添加
         */
        ADD_BY_PATIENT_SCAN_XCX(4);

        int type;

        public static String getScanType() {
            StringJoiner sj = new StringJoiner(",", "(", ")");
            sj.add(ADD_BY_SCAN_PATIENT.type + "").add(ADD_BY_PATIENT_SCAN.type + "").add(ADD_BY_PATIENT_SCAN_XCX.type + "");
            return sj.toString();
        }

        public static boolean isScan(int type) {
            return type >= ADD_BY_SCAN_PATIENT.type && type <= ADD_BY_PATIENT_SCAN_XCX.type;
        }

        public static DoctorPatientRelationType valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findFirst().orElse(null);
        }
    }

    /**
     * 医生认证状态
     */
    @AllArgsConstructor
    @Getter
    public enum DoctorVerifyState {

        /**
         * 未认证
         */
        TO_VERIFY(0),
        /**
         * 已认证
         */
        VERIFY_SUCCESS(1),
        /**
         * 认证中
         */
        VERIFING(2),
        /**
         * 认证失败
         */
        VERIFY_FAILURE(3);

        int state;

        public static DoctorVerifyState valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.state, type)).findFirst().orElse(null);
        }
    }

    /**
     * 医生查询患者类型
     */
    @AllArgsConstructor
    @Getter
    public enum DoctorQueryPatientType {

        /**
         * 今日测量
         */
        MEASURE_TODAY(1),
        /**
         * 重点关注
         */
        CONCERN(2),
        /**
         * 未测量
         */
        UN_MEASURE(3),
        /**
         * 扫码患者
         */
        SCAN_PATIENT(4);

        int type;

        public static DoctorQueryPatientType valueOf(Integer type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.type, type)).findFirst().orElse(null);
        }
    }

    /**
     * 关注状态
     */
    @AllArgsConstructor
    @Getter
    public enum DoctorConcernPatientStatus {

        /**
         * 取关/未关注
         */
        UNCONCERN(1),
        /**
         * 关注
         */
        CONCERN(2);

        int status;

    }

    /**
     * 二维码类型
     */
    @Getter
    @AllArgsConstructor
    public enum DEFAULT_ADDRESS {
        /**
         * 1. 默认地址
         */
        YES(1),
        /**
         * 2. 非默认地址
         */
        NO(0);

        private int type;
    }

    /**
     * 实验室检查项，用于数据获取
     */
    @AllArgsConstructor
    @Getter
    public enum LABORATORY {

        // 糖化血红蛋白
        HBA1C(1, "hba1c", "hba1c_date", 1, 3, "<7.0"),
        // 总胆固醇
        TC(2, "tc", "tc_date", 1, 3, "<4.5"),
        // 甘油三脂TG
        TG(3, "tg", "tg_date", 1, 3, "<1.7"),
        // 低密度脂蛋白
        LDL_C(4, "ldlc", "ldlc_date", 1, 3, "<2.6"),
        // 高密度脂蛋白
        HDL_C(5, "hdlc", "hdlc_date", 1, 3, ">1.0"),
        // 谷丙转氨酶
        ALT(6, "alt", "alt_date", 1, 3, "7~40"),
        // 总胆红素
        TBIL(7, "tbil", "tbil_date", 1, 3, "0~23"),
        // 谷草转氨酶
        AST(8, "ast", "ast_date", 1, 3, "13~35"),
        // 碱性磷酸酶
        ALP(9, "alp", "alp_date", 1, 3, "40~110"),
        // 尿微量白蛋白
        UAE(10, "uae", "uae_date", 1, 3, "23~62"),
        // 24h尿白蛋白
        UAE24(11, "uae24", "uae24_date", 1, 3, "40~80"),
        // 尿白蛋白/尿肌酐
        ACR(12, "acr", "acr_date", 1, 3, "40~80"),
        // 血清肌酐
        CR(13, "cr", "cr_date", 1, 3, "44~133"),
        // 尿素氮
        UREA_NITROGEN(14, "urea_nitrogen", "urea_nitrogen_date", 1, 3, "3.2~7.1"),
        // 肾小球滤过率
        GFR(15, "gfr", "gfr_date", 1, 3, "600~1000"),
        // 内生肌酐清除率
        CREATININE_RATE(16, "creatinine_rate", "creatinine_rate_date", 1, 3, "0.45~1.32"),
        // 空腹血糖
        FBG(17, "sugar_fasting", "sugar_fasting_date", 1, 3, "6.0~8.0"),
        // 餐后血糖
        PBG(18, "sugar_after2", "sugar_after2_date", 1, 3, "6.0~8.0"),
        // 血尿酸
        BUA(19, "bua", "bua_date", 1, 3, "180~420");

        int type;
        String name;
        String time;
        // 设置高低值，1代表向上箭头，3代表向下箭头
        int high;
        int low;
        // 设置参考值, 尽量使用TargetProject下的引用值
        String referenceValue;

        public static LABORATORY valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(HBA1C);
        }
    }

    /**
     * 用于查询身高体重BMI，获取一条最初的身高体重数值记录
     */
    @AllArgsConstructor
    @Getter
    public enum HEIGHT_WEIGHT {

        // BMI
        BMI(1, "height_weight_bmi"),
        WEIGHT(2, "height_weight_weight");

        int type;
        String name;

        public static HEIGHT_WEIGHT valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(BMI);
        }
    }

    /**
     * 用于查询舒张压，收缩压，心率，获取一条最初的数值记录
     */
    @AllArgsConstructor
    @Getter
    public enum BloodPressure {

        // BMI
        PRESSURE_LOW(1, "blood_pressure_low_voltage"),
        PRESSURE_HIGH(2, "blood_pressure_high_pressure"),
        HEART_RATE(3, "blood_pressure_heart_rate");

        int type;
        String name;

        public static BloodPressure valueOf(int type) {
            return Arrays.stream(values()).filter(c -> Objects.equals(c.getType(), type)).findAny().orElse(PRESSURE_LOW);
        }
    }
}
